package cn.spark.study.core

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object ParallelizCollection {
  def main(args: Array[String]): Unit = {
    
    val conf = new SparkConf()
        .setAppName("ParallelizCollection")
        .setMaster("local")
    
    val sc = new SparkContext(conf)
    
    val list = Array(1,2,3,4,5,6,7,8,9,10)
    
    // 用SparkContext 或 其 子类 的 parallelize方法创建RDD scala 版本的 parallelize要求指定创建几个 partition 此处指定5个
    val numbers = sc.parallelize(list, 5)
    val sum = numbers.reduce(_ + _)
    
    println(sum);
  }
}